package org.flex
{
	import flash.events.EventDispatcher;
	import flash.net.*;
	public class User extends EventDispatcher
	{
		private static const SUBMIT_URL:String = "http://localhost:8080/collaboration/api/submit";
		
		[Bindable]
		public var firstname:String;
		[Bindable]
		public var username:String;
		[Bindable]
		public var lastname:String;
		
		private var submitStoryLoader:URLLoader;
		private var voteStoryLoader:URLLoader;
		
		private static var listStoriesLoader:URLLoader;
		
		public function User()
		{
		}
		
		public function save():void
		{
			var req:URLRequest = new URLRequest(SUBMIT_URL);
			req.method = URLRequestMethod.POST;
			var params:URLVariables = new URLVariables();
			params.firstName = firstname;
			params.lastName = lastname;
			params.userName = username;
			req.data = params;
			submitStoryLoader = new URLLoader(req);
			submitStoryLoader.addEventListener(Event.COMPLETE, submitSuccessHandler);
			//submitStoryLoader.addEventListener(IOErrorEvent.IO_ERROR, submitErrorHandler);
			submitStoryLoader.load(req);
		}
		
		private function submitSuccessHandler(e:Event):void
		{
			this.dispatchEvent(e);
		}
			
		private function submitErrorHandler(e:Event):void
		{
			
			this.dispatchEvent(e);
		}

	}
}